package top.continew.admin.req;

import cn.shengchao.examstar.rpc.distribute.dto.DistributeNodeInfoPercentDto;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import top.continew.admin.system.util.ValidateGroup;

import java.math.BigDecimal;

/**
 * @program: examstar-manger-api
 * @description: 创建内容分销链用户的接口
 * @author: Xiong weiqiang
 * @create: 2025-03-27 11:39
 */
@Data
public class DistributeUserSalePercentChangeRto {
    @NotNull(message = "用户不能为空",groups = {ValidateGroup.ReqGroup.SAVE.class, ValidateGroup.ReqGroup.UPDATE.class})
    private Long userId;
    @NotNull(message = "分销角色代码不能为空",groups = {ValidateGroup.ReqGroup.SAVE.class, ValidateGroup.ReqGroup.UPDATE.class})
    private String distributeRoleCode;
    @NotNull(message = "分成比例不能为空",groups = {ValidateGroup.ReqGroup.SAVE.class, ValidateGroup.ReqGroup.UPDATE.class})
    @DecimalMax(value = "45",message = "分成比例不能大于45",groups = {ValidateGroup.ReqGroup.SAVE.class, ValidateGroup.ReqGroup.UPDATE.class})
    private BigDecimal percentStable;

    public  static DistributeNodeInfoPercentDto toDto(DistributeUserSalePercentChangeRto rto){
        DistributeNodeInfoPercentDto dto = new DistributeNodeInfoPercentDto();
        dto.setUserId(rto.getUserId());
        dto.setDistributeRoleCode(rto.getDistributeRoleCode());
        dto.setPercentStable(rto.getPercentStable());
        return dto;
    }
}